package com.easipass.framework.eirframeworkcoredsl;

import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public abstract class LabelledServiceNode extends AstNode {

    private Token label;

    public LabelledServiceNode(int startPos, int endPos) {
        super(startPos, endPos);
    }

    public boolean isFlow() {
        return false;
    }

    public boolean isFunction() {
        return false;
    }

    public boolean isSplit() {
        return false;
    }

    public boolean isServiceApp() {
        return false;
    }

    public int getSeriesLength() {
        return -1;
    }

    public LabelledServiceNode getSeriesElement(int index) {
        return null;
    }

    public List<LabelledServiceNode> getSeries() {
        return null;
    }

    protected boolean hasLabel() {
        return this.label != null;
    }

    protected String getLabelString() {
        return hasLabel() ? this.label.stringValue() : null;
    }

    public Token getLabel() {
        return this.label;
    }

    public void setLabel(Token label) {
        this.label = label;
    }

    public String getName(){
        return "";
    }

    public ArgumentNode[] getArguments(){
        return null;
    }

    public Map<String,String> getArgumentsAsMap(){
        Map<String, String> argumentsMap = Collections.emptyMap();
        ArgumentNode[] arguments = getArguments();
        if (arguments != null && arguments.length > 0) {
            argumentsMap = new LinkedHashMap<String, String>();
            for (ArgumentNode argument : arguments) {
                argumentsMap.put(argument.getName(), argument.getValue());
            }
        }
        return argumentsMap;
    }

    public String getExecutableDSLName(){
        return null;
    }
}
